﻿(function () {
    'use strict';

    define([
        'dojo/_base/Color',
        'esri/symbol'
    ], function (Color, Symbol) {
        return {
            GetGeometryString: function (geometry) {
                var str = "";
                switch (geometry.type) {
                    case "polygon":
                        str += "POLYGON((";
                        for (var i = 0; i < (geometry.rings[0].length - 1) ; i++) {
                            str += geometry.rings[0][i][0] + " " + geometry.rings[0][i][1] + ",";
                        }
                        var last_i = geometry.rings[0].length - 1;
                        str += geometry.rings[0][last_i][0] + " " + geometry.rings[0][last_i][1];
                        str += "))";
                        break;
                    case "extent":
                        str += "POLYGON((";
                        str += geometry.xmin.toString() + " " + geometry.ymin.toString() + ","
                            + geometry.xmin.toString() + " " + geometry.ymax.toString() + ","
                            + geometry.xmax.toString() + " " + geometry.ymax.toString() + ","
                            + geometry.xmax.toString() + " " + geometry.ymin.toString() + ","
                            + geometry.xmin.toString() + " " + geometry.ymin.toString();
                        str += "))";
                        break;
                    default:
                        break;
                }
                return str;
            },
            GetGeometryStringShort: function (geometry) {
                var str = "";
                switch (geometry.type) {
                    case "polygon":
                        str += "'POLYGON((";
                        for (var i = 0; i < (geometry.rings[0].length - 1) ; i++) {
                            str += geometry.rings[0][i][0] + " " + geometry.rings[0][i][1] + ",";
                        }
                        var last_i = geometry.rings[0].length - 1;
                        str += geometry.rings[0][last_i][0] + " " + geometry.rings[0][last_i][1];
                        str += "))'";
                        break;
                    case "extent":
                        str += "'POLYGON((";
                        str += geometry.xmin.toString() + " " + geometry.ymin.toString() + ","
                            + geometry.xmin.toString() + " " + geometry.ymax.toString() + ","
                            + geometry.xmax.toString() + " " + geometry.ymax.toString() + ","
                            + geometry.xmax.toString() + " " + geometry.ymin.toString() + ","
                            + geometry.xmin.toString() + " " + geometry.ymin.toString();
                        str += "))'";
                        break;
                }
                return str;
            },
            simpleCrossMarker: function () {
                return new Symbol.SimpleMarkerSymbol(Symbol.SimpleMarkerSymbol.STYLE_CROSS, 10,
                    new Symbol.SimpleLineSymbol(Symbol.SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1),
                    new Color([255, 0, 0, 1]));
            },
            simplePictureMarker: function () {
                var pms = new Symbol.PictureMarkerSymbol("./images/esriGreenPin.png", 16, 26);
                pms.setOffset(0, 13);
                return pms;
            },
            selectedPolygonSymbol: function () {
                //STYLE_SOLID, STYLE_NULL, STYLE_BACKWARD_DIAGONAL, STYLE_FORWARD_DIAGONAL
                return new Symbol.SimpleFillSymbol(Symbol.SimpleFillSymbol.STYLE_BACKWARD_DIAGONAL, new Symbol.SimpleLineSymbol(Symbol.SimpleLineSymbol.STYLE_SOLID, new Color([0, 255, 255]), 2), new Color([100, 100, 100, 0.25]));
            },
            polygonSymbol: function () {
                return new Symbol.SimpleFillSymbol(Symbol.SimpleFillSymbol.STYLE_SOLID, new Symbol.SimpleLineSymbol(Symbol.SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([100, 100, 100, 0.25]));
            }
        };
    });
}).call(this);